<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        Function.prototype.myApply = function(ctx,arrargs){

            ctx = ctx||window
            ctx.fn = this;
            if(!arrargs){
                let res = ctx.fn()
                return res
            }
            let res = ctx.fn(...arrargs);
            delete ctx.fn
            return res
        }
        


        function method(a, b) {
            console.log(this, a, b);
            return a + b;
        }
        function a()
        {
            console.log(1)
        }

        method.myApply({}, [1,2])
        a.myApply({})
    </script>
</body>
</html>